import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;

import java.io.IOException;
import java.util.Arrays;

/**
 * HttpClient使用示例 jar包：commons-httpclient.jar
 */
public class HttpClientTest {
	// 1.2.2 医生登陆
	private static void doGetDoctorlogin(String usrID, String usrPwd) {
		HttpClient client = new HttpClient();
		GetMethod getMethod = new GetMethod(
				"http://192.168.123.66:8008/post/Doctorlogin?" + "usrID=" + usrID + "&" + "usrPwd=" + usrPwd);
		int code = 0;
		try {
			code = client.executeMethod(getMethod);
			if (code == 200) {
				String res = getMethod.getResponseBodyAsString();
				System.out.println(res);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	// 1.5现场专家挂号
	private static void doGetproLive(String usrID, String subject) {
		HttpClient client = new HttpClient();
		GetMethod getMethod = new GetMethod(
				"http://192.168.123.66:8008/post/proLive?" + "usrID=" + usrID + "&" + "subject=" + subject);
		int code = 0;
		try {
			code = client.executeMethod(getMethod);
			if (code == 200) {
				String res = getMethod.getResponseBodyAsString();
				System.out.println(res);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	// 1.6现场科室挂号
	private static void doGetdepLive(String usrID, String subject) {
		HttpClient client = new HttpClient();
		GetMethod getMethod = new GetMethod(
				"http://192.168.123.66:8008/post/depLive?" + "usrID=" + usrID + "&" + "subject=" + subject);
		int code = 0;
		try {
			code = client.executeMethod(getMethod);
			if (code == 200) {
				String res = getMethod.getResponseBodyAsString();
				System.out.println(res);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	// 1.7预约专家分诊
	private static void doGetorderProTriage(String usrID) {
		HttpClient client = new HttpClient();
		GetMethod getMethod = new GetMethod("http://192.168.123.66:8008/post/depLive?usrID=" + usrID);
		int code = 0;
		try {
			code = client.executeMethod(getMethod);
			if (code == 200) {
				String res = getMethod.getResponseBodyAsString();
				System.out.println(res);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	// 1.8预约科室分诊
	private static void doGetorderDepTriage(String usrID) {
		HttpClient client = new HttpClient();
		GetMethod getMethod = new GetMethod("http://192.168.123.66:8008/post/orderDepTriage?" + "usrID=" + usrID);
		int code = 0;
		try {
			code = client.executeMethod(getMethod);
			if (code == 200) {
				String res = getMethod.getResponseBodyAsString();
				System.out.println(res);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	// 1.9现场科室分诊
	private static void doGetliveDepTriage(String usrID) {
		HttpClient client = new HttpClient();
		GetMethod getMethod = new GetMethod("http://192.168.123.66:8008/post/liveDepTriage?" + "usrID=" + usrID);
		int code = 0;
		try {
			code = client.executeMethod(getMethod);
			if (code == 200) {
				String res = getMethod.getResponseBodyAsString();
				System.out.println(res);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	// 1.10现场专家分诊
	private static void doGetliveProTriage(String usrID) {
		HttpClient client = new HttpClient();
		GetMethod getMethod = new GetMethod("http://192.168.123.66:8008/post/liveProTriage?" + "usrID=" + usrID);
		int code = 0;
		try {
			code = client.executeMethod(getMethod);
			if (code == 200) {
				String res = getMethod.getResponseBodyAsString();
				System.out.println(res);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	// 2.1病历编辑
	private static void doGetmedicalRecordEdit(medicalRecord rc) {
		HttpClient client = new HttpClient();
		GetMethod getMethod = new GetMethod("http://192.168.123.66:8008/post/medicalRecordEdit?" + "ID=" + rc.getID()
				+ "&" + "recNum=" + rc.getRecNum() + "&" + "recDate=" + rc.getRecDate() + "&" + "subject="
				+ rc.getSubject() + "&" + "seeType=" + rc.getSeeType() + "&" + "name=" + rc.getName() + "&" + "gender="
				+ rc.getGender() + "&" + "age=" + rc.getAge() + "&" + "workType=" + rc.getWorkType() + "&" + "phone="
				+ rc.getPhone() + "&" + "addr=" + rc.getAddr() + "&" + "onsetDate=" + rc.getOnsetDate() + "&"
				+ "diagnosis=" + rc.getDiagnosis() + "&" + "drugHistory=" + rc.getDrugHistory() + "&" + "mainComplaint="
				+ rc.getMainComplaint() + "&" + "curMedicalHistory=" + rc.getMainComplaint());
		int code = 0;
		try {
			code = client.executeMethod(getMethod);
			if (code == 200) {
				String res = getMethod.getResponseBodyAsString();
				System.out.println(res);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	// 2.2申请单编辑
	private static void doGetrequisitionEdit(requisition re) {
		HttpClient client = new HttpClient();
		GetMethod getMethod = new GetMethod("http://192.168.123.66:8008/post/requisitionEdit?" + "ID=" + re.getID()
				+ "&" + "name=" + re.getName() + "&" + "gender=" + re.getGender() + "&" + "age=" + re.getAge() + "&"
				+ "workType=" + re.getWorkType() + "&" + "addr=" + re.getAddr() + "&" + "subjectRoom="
				+ re.getSubjectRoom() + "&" + "medicalSum=" + re.getMedicalSum() + "&" + "clinicalDia="
				+ re.getClinicalDia() + "&" + "checkPart=" + re.getCheckPart() + "&" + "warning=" + re.getWarning());
		int code = 0;
		try {
			code = client.executeMethod(getMethod);
			if (code == 200) {
				String res = getMethod.getResponseBodyAsString();
				System.out.println(res);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	// 2.3处方单编辑
	private static void doGetprescriptionEdit(prescription pr) {
		HttpClient client = new HttpClient();
		
		String durginfo;
		durginfo=Arrays.toString(pr.getDrugs());
		
		GetMethod getMethod = new GetMethod(
				"http://192.168.123.66:8008/post/prescriptionEdit?" + "ID=" + pr.getID() + "&" + "drugCol="
						+ pr.getDrugCol() + "&" + durginfo + "&" + "totPrice=" + pr.getTotPrice());
		int code = 0;
		try {
			code = client.executeMethod(getMethod);
			if (code == 200) {
				String res = getMethod.getResponseBodyAsString();
				System.out.println(res);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	// 3.1申请单收费
	private static void doGetrequisitionCharge(String requisitionNum) {
		HttpClient client = new HttpClient();
		GetMethod getMethod = new GetMethod(
				"http://192.168.123.66:8008/post/requisitionCharge?" + "requisitionNum=" + requisitionNum);
		int code = 0;
		try {
			code = client.executeMethod(getMethod);
			if (code == 200) {
				String res = getMethod.getResponseBodyAsString();
				System.out.println(res);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	// 3.2处方单收费
	private static void doGetprescriptionChrge(String prescriptionNum) {
		HttpClient client = new HttpClient();
		GetMethod getMethod = new GetMethod(
				"http://192.168.123.66:8008/post/prescriptionChrge?" + "prescriptionNum=" + prescriptionNum);
		int code = 0;
		try {
			code = client.executeMethod(getMethod);
			if (code == 200) {
				String res = getMethod.getResponseBodyAsString();
				System.out.println(res);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	// 3.3退检验费
	private static void doGetrequisitionRefund(String requisitionNum) {
		HttpClient client = new HttpClient();
		GetMethod getMethod = new GetMethod(
				"http://192.168.123.66:8008/post/prescriptionChrge?" + "requisitionNum=" + requisitionNum);
		int code = 0;
		try {
			code = client.executeMethod(getMethod);
			if (code == 200) {
				String res = getMethod.getResponseBodyAsString();
				System.out.println(res);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	// 3.4退药费
	private static void doGetprescriptionRefund(String prescriptionNum) {
		HttpClient client = new HttpClient();
		GetMethod getMethod = new GetMethod(
				"http://192.168.123.66:8008/post/prescriptionRefund?" + "prescriptionNum=" + prescriptionNum);
		int code = 0;
		try {
			code = client.executeMethod(getMethod);
			if (code == 200) {
				String res = getMethod.getResponseBodyAsString();
				System.out.println(res);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	// 4.1配药
	private static void doGetdispensing(String prescriptionNum) {
		HttpClient client = new HttpClient();
		GetMethod getMethod = new GetMethod(
				"http://192.168.123.66:8008/post/dispensing?" + "prescriptionNum=" + prescriptionNum);
		int code = 0;
		try {
			code = client.executeMethod(getMethod);
			if (code == 200) {
				String res = getMethod.getResponseBodyAsString();
				System.out.println(res);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	// 4.2发药
	private static void doGetconfirmMedi(String prescriptionNum) {
		HttpClient client = new HttpClient();
		GetMethod getMethod = new GetMethod(
				"http://192.168.123.66:8008/post/confirmMedi?" + "prescriptionNum=" + prescriptionNum);
		int code = 0;
		try {
			code = client.executeMethod(getMethod);
			if (code == 200) {
				String res = getMethod.getResponseBodyAsString();
				System.out.println(res);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	// 4.3退药
	private static void doGetdrugWithdrawal(String prescriptionNum) {
		HttpClient client = new HttpClient();
		GetMethod getMethod = new GetMethod(
				"http://192.168.123.66:8008/post/drugWithdrawal?" + "prescriptionNum=" + prescriptionNum);
		int code = 0;
		try {
			code = client.executeMethod(getMethod);
			if (code == 200) {
				String res = getMethod.getResponseBodyAsString();
				System.out.println(res);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}